package com.mbigger.netty.ch8.in;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.compression.JdkZlibDecoder;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class InBoundHandler extends SimpleChannelInboundHandler<String> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
        log.info("MyInBoundHandler: " + msg);
        ctx.pipeline().replace(JdkZlibDecoder.class, "zlibDecoder", new JdkZlibDecoder());
        String content = "hello, netty!";
        ctx.channel().writeAndFlush(content);
    }

}
